<?php
// 本文档自动生成，仅供测试运行
class IndexAction extends Action
{
    /**
    +----------------------------------------------------------
    * 默认操作
    +----------------------------------------------------------
    */
    public function index()
    {
		$dept = $_GET['dept'];
		$data=$this->getAllAddress();
		$this->assign('address',$data);
		$data=$this->getAllCategory();
		$this->assign("category",$data);
		
        $data=$this->getAllProject();
        $this->assign("project",$data);
		$this->display();
    }
	
	public function getCategoryName($id){
		if($_POST['id']){
			$id = $_POST['id'];
		}
		$Dao = M('Category');
		$data = $Dao->where("category_id = $id")->find();
		//return $data;
		//dump($data);
	}
	
	public function getAllProject() {
		$Pro=D("project");
		$data=$Pro->select();
		return $data;
	}
	public function getAllCategory() {
		$Cate=D("category");
		$data=$Cate->select();
		return $data;
	}
	public function getCategoryByProID($proid) {
		$Cate=D("category");
		$data=$Cate->where(" belong_project_id = $proid ")->select();
		return $data;
	}
	public  function getAllAddress() {
		$Addr=D("address");
		$data=$Addr->select();
		return $data;
	}
	
	public function getAddressbyCateID($cateid) {
		$Addr=D("addrss");
		$data=$Addr->while ("address_cate_id = $cateid")->find();
		return $data;
	}
	
	public function onClickProject($proid) {
		$data=$this->getAllProject();
		$this->assign("project",$data);
		
		$data=$this->getCategoryByProID($proid);
		$this->assign("category",$data);
		echo "cate under proid:$proid";
		dump($data);
		
		$Cate=D("category");
		$cateone=$Cate->where("belong_project_id = $proid")->select();//查寻一条记录
		dump($cateone);
		$Addr=D("address");
		$data=$Addr->where("address_cate_id = $cateone[address_cate_id]")->select();
		$this->assign("address",$data);
		$this->display();
	}


    /**
    +----------------------------------------------------------
    * 探针模式
    +----------------------------------------------------------
    */
    public function checkEnv()
    {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }

}
?>